<?php
/**
 * Subcategoryadmin_Model_Subcategoryadmin
 * sub categry admin model
 *
 * @author Adrian Stolarski
 */
class Subcategoryadmin_Model_Subcategoryadmin implements Subcategoryadmin_Model_Mainable, 
        Subcategoryadmin_Model_Decidable {
    
    /**
     *
     * @var type $action_helper
     * action helper handler
     */
    public $action_helper;
    
    /**
     * main()
     * sub category model main decision
     * 
     * @param array $variables
     * @return type current model data
     */
    public function main(array $variables = null) {
        return $this->model_decision($variables);
    }

    /**
     * model_decision()
     * main model action decision
     * 
     * @param array $variables
     * @return current action type
     */
    public function model_decision(array $variables = null) {
        //var_dump($variables);
        //die();
        switch ($variables['get']['name']){
            case "sub_categories_list":
                return $this->sub_categories_list($variables);
                break;
            case "delete_sub_category":
                $this->delete_sub_category($variables['post']);
                break;
            case "update_sub_category":
                $this->update_sub_category($variables['post']);
                break;
            case "edit_sub_category":
                return $this->edit_sub_category($variables['post']);
                break;
            case "insert_sub_category":
                $this->insert_sub_category($variables['post']);
                break;
            case "add_sub_category":
                //var_dump($variables);
                //die();
                return $this->add_sub_category($variables);
                break;
            default:
                return $this->sub_categories_list($variables);
                break;
        } 
    }
    
    /**
     * add_sub_category()
     * add new sub category data
     * 
     * @param array $variables
     * @return type Subcategoryadmin_Data_Addsubcategory
     */
    private function add_sub_category(array $variables = null){
        //var_dump($variables);
        //die();
        $this->action_helper = new Subcategoryadmin_Data_Addsubcategory;
        return $this->action_helper->main($variables);
    }
    
    /**
     * insert_sub_category()
     * insert new subcategory
     * 
     * @param array $variables
     */
    private function insert_sub_category(array $variables = null){
        //var_dump($variables);
        //die();
        $this->action_helper = new Subcategoryadmin_Model_Insertsubcategory;
        $this->action_helper->main($variables);
    }
    
    /**
     * edit_sub_category()
     * edit current sub category template data
     * 
     * @param array $variables
     * @return type Subcatgoryadmin_Model_Editsubcategory
     */
    private function edit_sub_category(array $variables = null){
       $this->action_helper = new Subcategoryadmin_Model_Editsubcategory;
       return $this->action_helper->main($variables);
    }
    
    /**
     * update_sub_category()
     * update current sub category
     * 
     * @param array $variables
     */
    private function update_sub_category(array $variables = null){
        //var_dump($variables);
        //die();
        $this->action_helper = new Subcategoryadmin_Model_Udpatesubcategory;
        $this->action_helper->main($variables);
    }
    
    /**
     * delete_sub_category()
     * delete current sub category
     * 
     * @param array $variables
     */
    private function delete_sub_category(array $variables = null){
        $this->action_helper = new Subcategoryadmin_Model_Deletesubcategory;
        $this->action_helper->main($variables);
    }
    
    /**
     * sub_categories_list()
     * get sub categories list
     * @param array $variables
     * @return type Subcategoryadmin_Data_Subcategorieslist
     */
    private function sub_categories_list(array $variables = null){
        //var_dump($variables);
        //die();
        $this->action_helper = new Subcategoryadmin_Data_Subcategorieslist;
        return $this->action_helper->main($variables);
    }

}
